/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Author:Nicolas Longuet Marx
Date: June 20 2020
Last modified: August 19 2023
Object: Produce Tables for the Online Appendix (OA)
Databases in input: A_experiment.dta
Databases in output: None

Tables generated in this script:

- Table E.2. Descriptive statistics and balance tests.
- Table E.3. Impact on the perceived seriousness of the health and economic consequences of the crisis.
- Table E.4. Impact on satisfaction with the government's response to the crisis.
- Table E.5. Satisfaction with the health and economic measures, first stage.
- Table E.6. Satisfaction with the head of government, first stage.
- Table E.7. OLS estimates of the correlation between satisfaction with the head of government and attitudes on democracy.
- Table E.8. Impact on political efficacy - 2SLS.
- Table E.9: Impact on satisfaction with democracy, excluding Brazil and Poland - 2SLS.
- Table E.10: Impact on support for democratic ideals, excluding Brazil and Poland - 2SLS.
- Table E.12: Impact on satisfaction with democracy, depending on exposure to Covid-19 
- Table E.14: Impact on satisfaction with democracy, treatments mentioning government - 2SLS.
- Table E.15: Impact on support for democracy, treatments mentioning government - 2SLS.	
- Table E.16: Impact on satisfaction with democracy, additional regressors - 2SLS.
- Table E.17: Impact on support for democracy, additional regressors - 2SLS.
- Table E.18: Impact of the health and economic consequences of the crisis on satisfaction with the regional government.
- Table E.19: Impact of satisfaction with the regional government on satisfaction with democracy.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ****/

**# 0. Prepare data 

use "1_data/A_experiment.dta", replace


/* program to export estimation results better */
qui do "2_code/mylincom_program.do"
qui do "2_code/get_mean_program.do"
qui do "2_code/mylincom_program_2sls.do"


/* CONTROLS AND MISSING VALUES */
global controls "thirties fourties fifties sixties seventies income2quartile income3quartile income4quartile incomenoanswer female highschool college noreligion christiannotcatholic catholic fulltimeworker parttimeworker unemployed selfemployed outofLF goodhealth white black latino asian whitecollar bluecollar serviceworker"

global mv_controls
foreach y of global controls {
	global mv_controls $mv_controls mv_`y'
	gen mv_`y' = (`y' == .)
	replace `y' = 0 if `y' == .
}

foreach var of varlist $controls $mv_controls {
	assert `var'!= .
}


* Check that treatment is well defined
foreach var of varlist blame* praisi* bad_* TH* TE* treatc* healthc* econc* {
	di "`var'"
	assert `var'!= .
}

decode country, gen(country_str)

**# Table E.2. Descriptive statistics and balance tests. 

matrix mat1 = J(8,3,.)

la var thirties "Thirties"
la var fourties "Fourties"
la var fifties "Fifties"
la var sixties "Sixties"
la var seventies "Seventies"
la var income2quartile "Income, 2nd quartile"
la var income3quartile "Income, 3rd quartile"
la var income4quartile "Income, 4th quartile"
la var incomenoanswer "Income, no answer"
la var female "Female"
la var highschool "High school degree"
la var college "College degree"
la var noreligion "No religion"
la var christiannotcatholic "Christian, not catholic"
la var catholic "Catholic"
la var fulltimeworker "Full-time worker"
la var parttimeworker "Part-time worker"
la var unemployed "Unemployed"
la var selfemployed "Self-employed"
la var outofLF "Out of labor force"
la var goodhealth "Good health situation"
la var white "White"
la var black "Black"
la var latino "Latinx"
la var asian "Asian origin"
la var whitecollar "White-collar"
la var bluecollar "Blue-collar"
la var serviceworker "Service worker"

global control_for_balancedness $controls  
local num : list sizeof global(control_for_balancedness)
matrix stats = J(`num',4,.)
local pos = 1
local rownames
foreach var of global control_for_balancedness {
	local lab: variable label `var' 
	local rownames `rownames' "`lab'"
	qui su `var'
	matrix stats[`pos',1] = `r(mean)'
	matrix stats[`pos',2] = `r(sd)'
	qui reg `var' TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3 
	matrix stats[`pos',3] = e(F)
	matrix stats[`pos',4] = Ftail(e(df_m), e(df_r), e(F))
	local pos = `pos'+1
}

matrix rownames stats = `rownames'
mat colnames stats = "Mean" "sd" "F-stat" "p-value" 
esttab matrix(stats, fmt(3 3 3 3)) using "3_output/2_OA/Tables/TableE2.tex", replace nomtitles


**# Table E.3. Impact on the perceived seriousness of the health and economic consequences of the crisis.
la var serious_h_csqc "Very serious health consequences"
la var serious_e_csqc "Beliefs on Econ csqc"
la var satis_head "Satisfaction with the head of government"

eststo clear
eststo: reg serious_h_csqc bad_health_situation bad_econ_situation, robust
get_mean

eststo: reg serious_h_csqc bad_health_situation bad_econ_situation $controls $mv_controls  i.country, robust
estadd local Controls "X", replace
estadd local Country_FE "X", replace
get_mean

eststo: reg serious_e_csqc bad_health_situation bad_econ_situation, robust
get_mean

eststo: reg serious_e_csqc bad_health_situation bad_econ_situation $controls $mv_controls  i.country, robust
estadd local Controls "X", replace
estadd local Country_FE "X", replace
get_mean

esttab using "3_output/2_OA/Tables/TableE3.tex", r2 dep nocons ///
	keep(_cons bad_health_situation bad_econ_situation ) ///
	order(_cons bad_health_situation bad_econ_situation ) ///
	label replace 	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $/times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls Country_FE N r2 av, fmt(%15.0fc %15.0fc %15.0fc %6.3f %6.3f ) layout(@ @ @ @ @) ///
	labels("Individual controls" "Country FE" Observations R2 "Outcome mean")) ///
	collabels(none) mlabels(none) ///
	mgroups("Very serious health consequences" "Very serious economic consequences" , pattern(1 0 1 0 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) 

	
**# Table E.4. Impact on satisfaction with the government's response to the crisis.		
eststo clear
eststo: reg eval_sant bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ, robust
mylincom3
get_mean

eststo: reg eval_sant bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ $controls $mv_controls  i.country, robust
estadd local Controls "X", replace
estadd local Country_FE "X", replace
mylincom3
get_mean

eststo: reg eval_eco bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ, robust
mylincom3
get_mean

eststo: reg eval_eco bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ $controls $mv_controls  i.country, robust
estadd local Controls "X", replace
estadd local Country_FE "X", replace
mylincom3
get_mean

esttab using "3_output/2_OA/Tables/TableE4.tex", depvar cons ///
	keep(bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ ) ///
	order(bad_health_situation blame_gov_health praising_gov_health bad_econ_situation blame_gov_econ praising_gov_econ ) ///
	label replace 	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $/times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls Country_FE N r2 av nothing nothing2 blameh blamehsd blamee seblamee, fmt(%15.0fc %15.0fc %15.0fc %9.3f %15.3fc %15.3fc %15.3fc %15.3fc %15.3fc) layout(@ @ @ @ @ @ @ @ (@) @ (@)) ///
	labels("Individual controls" "Country FE" Observations R2 "Outcome mean" " " "Linear combination of estimates:" "Blaming - Praising health policy" " " "Blaming - Praising economic policy" " ")) ///
	collabels(none) mlabels(none) ///
	mgroups("Health satisfaction" "Economic satisfaction", pattern(1 0 1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	
	
	
**# Table E.5. Satisfaction with the health and economic measures, first stage.
eststo clear
eststo: reg eval_sant TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3, robust
estadd scalar F = e(F), replace

eststo: reg eval_sant TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3 $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3
estadd scalar F = r(F), replace

eststo: reg eval_sant healthc econc, robust
estadd scalar F = e(F), replace
	
eststo: reg eval_sant healthc econc $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  healthc econc
estadd scalar F = r(F), replace

eststo: reg eval_eco TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3, robust
estadd scalar F = e(F), replace

eststo: reg eval_eco TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3 $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3
estadd scalar F = r(F), replace

eststo: reg eval_eco healthc econc , robust
estadd scalar F = e(F), replace

eststo: reg eval_eco healthc econc $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  healthc econc
estadd scalar F = r(F), replace

esttab using "3_output/2_OA/Tables/TableE5.tex", depvar keep(TH* healthc econc) cons ///
label replace order(_cons healthc econc TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N  F , layout(@ @ @ @  ) fmt(%15s %15s %15.0fc %9.3f) labels("Controls" "Country FE" Observations  "F-statistic")) ///
	collabels(none) mlabels(none) ///
	mgroups("Health satisfaction" "Economic satisfaction" , pattern(1 0 0 0 1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

		
**# Table E.6. Satisfaction with the head of government, first stage.
eststo clear
eststo: reg satis_head TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3, robust
estadd scalar F = e(F), replace

eststo: reg satis_head TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3 $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3
estadd scalar F = r(F), replace

eststo: reg satis_head healthc econc, robust
estadd scalar F = e(F), replace

eststo: reg satis_head healthc econc $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  healthc econc
estadd scalar F = r(F), replace

eststo: reg satis_head treatc, robust
estadd scalar F = e(F), replace

eststo: reg satis_head treatc $controls $mv_controls i.country, robust
estadd local CFE "X", replace
estadd local Controls "X", replace
test  treatc
estadd scalar F = r(F), replace

esttab using "3_output/2_OA/Tables/TableE6.tex", depvar keep(TH* healthc econc treatc) cons ///
	label replace order(_cons healthc econc treatc TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N  F , layout(@ @ @ @  ) fmt(%15s %15s %15.0fc %9.3f) labels("Controls" "Country FE" Observations  "F-statistic")) ///
	collabels(none) mlabels(none) ///
	mgroups("Satisfaction with the head of government" , pattern(1 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

**# Table E.7. OLS estimates of the correlation between satisfaction with the head of government and attitudes on democracy.

eststo clear
eststo: reg satis_dem satis_head,  robust 
get_mean

eststo: reg satis_dem satis_head  $controls $mv_controls i.country,  robust 
get_mean
estadd local Controls "X", replace
estadd local CFE "X", replace

eststo: reg democ satis_head,  robust 
get_mean

eststo: reg democ satis_head  $controls $mv_controls i.country,  robust 
get_mean
estadd local Controls "X", replace
estadd local CFE "X", replace

esttab using "3_output/2_OA/Tables/TableE7.tex", depvar nocons keep(satis_head) ///
	 label replace wrap ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av   , layout(@ @ @ @ ) fmt(%15s %15s %15.0fc %9.3f  ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" )) ///
	collabels(none) mlabels(none) ///
	mgroups("Satisfaction with democracy" "Democracy (support)"  , pattern(1 0 1 0 ) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span )


			
**# Table E.8. Impact on political efficacy - 2SLS.

eststo clear
/* E.8. Col 1: External Efficacy with 16 instruments */
eststo: ivreg2 gov_care_inv ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls  i.country, small robust 

estadd local Controls "X", replace
estadd local CFE "X", replace
estadd local IV "16 IVs", replace
estadd scalar fstat = e(widstat)
get_mean

/* E.8. Col 2: External Efficacy with 1 instrument */
eststo: ivreg2 gov_care_inv ///
	(satis_head = treatc) $controls $mv_controls  i.country, small robust 

estadd local IV "SumIV", replace
estadd scalar fstat = e(widstat)
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

/* E.8. Col 3: Internal Efficacy with 16 instruments */
eststo: ivreg2 complicated_inv ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls  i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "16 IVs", replace
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

/* E.8. Col 4: Internal Efficacy with 1 instrument */
eststo: ivreg2 complicated_inv ///
	(satis_head = treatc ) $controls $mv_controls  i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "SumIV", replace
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

/* E.8. Col 5: Standardized Index with 16 instruments */
eststo: ivreg2 index_efficacy ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls  i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "16 IVs", replace
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

/* E.8. Col 6: Standardized Index with 1 instrument */
eststo: ivreg2 index_efficacy ///
	(satis_head = treatc ) $controls $mv_controls  i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "SumIV", replace
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

esttab using "3_output/2_OA/Tables/TableE8.tex", depvar keep(satis_head) ///
	label replace wrap ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $/times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat , layout(@ @ @ @ @ @ ) fmt(%15s %15s %15.0fc %12.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" )) ////
	collabels(none) mlabels(none) ///
	mgroups("External efficacy" "Internal efficacy" "Standardized index" , pattern(1 0 1 0 1 0 ) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

	


/* Cross-national heterogeneity, excluding young democracies */ 
preserve

keep if country_str!= "Poland" & country_str!= "Brazil"

**# Table E.9: Impact on satisfaction with democracy, excluding Brazil and Poland - 2SLS.
/* E.9. Col 1: 16 instruments */
eststo clear
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust 

estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean

/* E.9. Col 2: 16 instruments + controls */
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 
	
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
	
/* E.9. Col 3: 2 instruments */	
eststo: ivreg2 satis_dem ///
	(satis_head = healthc econc), small robust 

estadd scalar fstat = e(widstat)
estadd local IV "2 SumIVs"
get_mean

/* E.9. Col 4: 2 instruments + controls */	
eststo: ivreg2 satis_dem ///
	(satis_head = healthc econc) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "2 SumIVs"
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

/* E.9. Col 5: 1 instrument */	
eststo: ivreg2 satis_dem ///
	(satis_head = treatc), small robust 

estadd scalar fstat = e(widstat)
estadd local IV "SumIV"
estadd local nothing nothing2 = " "
get_mean

/* E.9. Col 6: 1 instrument + controls */	
eststo: ivreg2 satis_dem ///
	(satis_head = treatc) $controls $mv_controls i.country, small robust 
	
estadd scalar fstat = e(widstat)
estadd local IV "SumIV"
estadd local nothing nothing2 = " "
estadd local Controls "X", replace
estadd local CFE "X", replace
get_mean

esttab using "3_output/2_OA/Tables/TableE9.tex", depvar keep(satis_head) ///
	 label replace wrap ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat , layout(@ @ @ @ @ @ ) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" )) ///
	collabels(none) mlabels(none) ///
	mgroups("Satisfaction with democracy" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
		

**# Table E.10: Impact on support for democratic ideals, excluding Brazil and Poland - 2SLS.
/* E.10. Col 1 */
eststo clear
eststo: ivreg2 strong_leader ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs", replace
get_mean

/* E.10. Col 2 */
eststo: ivreg2 strong_leader ///
	(satis_head = treatc) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "SumIV", replace
get_mean

/* E.10. Col 3 */
eststo: ivreg2 experts ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local IV "16 IVs", replace
estadd local Controls "X", replace
get_mean

/* E.10. Col 4 */
eststo: ivreg2 experts ///
	(satis_head = treatc ) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local IV "SumIV", replace
estadd local Controls "X", replace
get_mean

/* E.10. Col 5 */
eststo: ivreg2 army ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local IV "16 IVs", replace
estadd local Controls "X", replace
get_mean

/* E.10. Col 6 */
eststo: ivreg2 army ///
	(satis_head = treatc) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local IV "SumIV", replace
estadd local Controls "X", replace
get_mean

/* E.10. Col 7 */
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "16 IVs", replace
estadd local CFE "X", replace
estadd local Controls "X", replace
get_mean

/* E.10. Col 8 */
eststo: ivreg2 democ ///
	(satis_head = treatc ) $controls $mv_controls i.country, small robust 

estadd scalar fstat = e(widstat)
estadd local IV "SumIV", replace
estadd local CFE "X", replace
estadd local Controls "X", replace
get_mean

esttab using "3_output/2_OA/Tables/TableE10.tex", depvar keep(satis_head) ///
	label replace wrap ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat , layout(@ @ @ @ @ @) fmt(%15s %15s %15.0fc %12.3f %9.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" )) ////
	collabels(none) mlabels(none) ///
	mgroups("Strong leader" "Experts" "Army" "Democracy" , pattern(1 0 1 0 1 0 1 0 ) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

restore


**# Table E.12: Impact on satisfaction with democracy, depending on exposure to Covid-19 

** predicted GDP loss higher than 5%
gen econloss_country=1 if inlist(country_str, "Austria", "UK","Italy", "France", "Spain")
replace econloss_country=0 if inlist(country_str, "Australia",  "Sweden", "Germany", "Brazil",  "US",  "Poland", "New_Zealand")

** deaths per capita larger than 2 per 10,000. 
gen highmort_country=1 if inlist(country_str,  "France", "Italy", "UK", "US", "Sweden", "Brazil" ,   "Spain")
replace highmort_country=0 if inlist(country_str, "Austria", "Australia", "New_Zealand","Germany", "Poland")

assert econloss_country !=. & highmort_country!=.
la var highmort_country "High mortality country"
la var econloss_country "High economic losses country"

gen satis_head_highmort_country = satis_head*highmort_country
la var satis_head_highmort_country "High mortality $\times$ satisfaction with the head of government"
gen satis_head_econloss_country = satis_head*econloss_country 
la var satis_head_econloss_country "High econ losses $\times$ satisfaction with the head of government"


eststo clear

/* initial coefficient */
eststo: ivreg2 satis_dem ///
(satis_head = healthc econc), small robust 
estadd scalar fstat = e(widstat)
estadd local IV "2 SumIVs"
get_mean

/* Adding interaction with mortality */
eststo: ivreg2 satis_dem ///
	(satis_head satis_head_highmort_country  = (c.healthc c.econc)#i.highmort_country) highmort_country, small robust 
estadd scalar fstat = e(widstat)
estadd local IV "2 SumIVs"
get_mean
lincom satis_head + satis_head_highmort_country 
local ldifhealth = round(r(estimate), 0.001)
estadd local difhealth "$`ldifhealth'^{*}$"
estadd scalar sddifhealth = r(se) 

/* Adding interaction with economic losses */
eststo: ivreg2 satis_dem ///
(satis_head satis_head_econloss_country = (c.healthc c.econc)#i.econloss_country) econloss_country, small robust 
estadd scalar fstat = e(widstat)
estadd local IV "2 SumIVs"
get_mean
lincom satis_head + satis_head_econloss_country 
local ldifecon = round(r(estimate), 0.001)
estadd local difecon "$`ldifecon'^{**}$"
estadd scalar sddifecon = r(se) 
	
esttab using "3_output/2_OA/Tables/TableE12.tex", depvar nocons order(satis_head satis_head_highmort_country satis_head_econloss_country)  ///
	 label replace wrap ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat nothing difhealth sddifhealth difecon sddifecon, layout(@ @ @ @ @ @ @ @ (@) @ (@)) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" "Linear combination of estimates" "Satisfaction with the head of government +" "High mortality $\times$ satisfaction with the head of government" "Satisfaction with the head of government +" "High economic losses $\times$ satisfaction with the head of government")) ///
	collabels(none) mlabels(none) ///
	mgroups("Satisfaction with democracy" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span )
		
		
**# Table E.14: Impact on satisfaction with democracy, treatments mentioning government - 2SLS.

la var democ "Democracy"
la var serious_h_csqc "Very serious health consequences"
la var serious_e_csqc "Very serious economic consequences"
la var satis_head "Satisfaction with the head of government"

eststo clear
/* E.14. Col.1. Initial coefficient: 16 instruments */
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust 

estimates store mod1
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef1 = _b[satis_head]
local se1 = _se[satis_head]

** for Hausman later 
qui ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small 
estimates store mod1b

/* E.14. Col.2. Initial coefficient: 16 instruments + controls */
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
local coef2 = _b[satis_head]
local se2 = _se[satis_head]
get_mean

* for Hausman later															
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small 
estimates store mod2b

* Hausman test for the following regression 
qui ivreg2 satis_dem ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation, small
estimates store mod3b
hausman mod3b mod1b
local temp_hausman = r(p)

/* E.14. Col.3. 8 instruments */
eststo: ivreg2 satis_dem ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation, small robust

estimates store mod3
estadd scalar fstat = e(widstat)
estadd local IV "8 IVs"
estadd local nothing nothing2 = " "
estadd scalar hausman = `temp_hausman'
local coef3 = _b[satis_head]
local se3 = _se[satis_head]
get_mean

* Z-test 
local z_value = abs(`coef3'-`coef1')/sqrt(`se3'^2+`se1'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

* Hausman test for following regression
qui ivreg2 satis_dem ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation $controls $mv_controls i.country, small 
estimates store mod4b
hausman mod4b mod2b
local temp_hausman = r(p)

/* E.14. Col.4. 8 instruments + controls */
eststo: ivreg2 satis_dem ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4 ) bad_econ_situation bad_health_situation $controls $mv_controls i.country, small robust		

estimates store mod4
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "8 IVs"
estadd local nothing nothing2 = " "
estadd scalar hausman = `temp_hausman'
local coef4 = _b[satis_head]
local se4 = _se[satis_head]
get_mean

* Z-test
local z_value = abs(`coef4'-`coef2')/sqrt(`se4'^2+`se2'^2)
di `z_value'
estadd scalar wald = (1-normal(`z_value'))*2

local labgen: variable label satis_dem

esttab mod1 mod2 mod3 mod4 using "3_output/2_OA/Tables/TableE14.tex", depvar keep(satis_head bad_econ_situation bad_health_situation ) ///
	label replace ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat hausman wald, layout(@ @ @ @ @ @ @ @) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" "Hausman test p-value" "Z-test p-value")) ///
	collabels(none) mlabels(none) ///
	mgroups("`labgen'" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	
	
**# Table E.15: Impact on support for democracy, treatments mentioning government - 2SLS.	
eststo clear
/* E.15. Col.1. Initial coefficient: 16 instruments */
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust 

estimates store mod1
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef1 = _b[satis_head]
local se1 = _se[satis_head]

** for Hausman later 
qui ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small 
estimates store mod1b

/* E.15. Col.2. Initial coefficient: 16 instruments + controls */
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
local coef2 = _b[satis_head]
local se2 = _se[satis_head]
get_mean

* for Hausman later															
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small 
estimates store mod2b

* Hausman test for the following regression 
qui ivreg2 democ ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation, small
estimates store mod3b
hausman mod3b mod1b
local temp_hausman = r(p)

/* E.15. Col.3. 8 instruments */
eststo: ivreg2 democ ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation, small robust

estimates store mod3
estadd scalar fstat = e(widstat)
estadd local IV "8 IVs"
estadd local nothing nothing2 = " "
estadd scalar hausman = `temp_hausman'
local coef3 = _b[satis_head]
local se3 = _se[satis_head]
get_mean

* Z-test 
local z_value = abs(`coef3'-`coef1')/sqrt(`se3'^2+`se1'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

* Hausman test for following regression
qui ivreg2 democ ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4) bad_econ_situation bad_health_situation $controls $mv_controls i.country, small 
estimates store mod4b
hausman mod4b mod2b
local temp_hausman = r(p)

/* E.15. Col.4. 8 instruments + controls */
eststo: ivreg2 democ ///
	(satis_head = TE2 TE4 TH2 TH4 TH4_TE2 TH4_TE4 TH2_TE2 TH2_TE4 ) bad_econ_situation bad_health_situation $controls $mv_controls i.country, small robust		

estimates store mod4
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "8 IVs"
estadd local nothing nothing2 = " "
estadd scalar hausman = `temp_hausman'
local coef4 = _b[satis_head]
local se4 = _se[satis_head]
get_mean

* Z-test
local z_value = abs(`coef4'-`coef2')/sqrt(`se4'^2+`se2'^2)
di `z_value'
estadd scalar wald = (1-normal(`z_value'))*2

local labgen: variable label democ

esttab mod1 mod2 mod3 mod4 using "3_output/2_OA/Tables/TableE15.tex", depvar keep(satis_head bad_econ_situation bad_health_situation ) ///
	label replace ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat hausman wald, layout(@ @ @ @ @ @ @ @) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f ) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "F-statistic" "Hausman test p-value" "Z-test p-value")) ///
	collabels(none) mlabels(none) ///
	mgroups("`labgen'" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

			


**# Table E.16: Impact on satisfaction with democracy, additional regressors - 2SLS.
* Hausman test for following regression
qui ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small
estimates store mod1b

eststo clear
/* E.16. Col.1. Initial coefficient: 16 instruments */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod1
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef1 = _b[satis_head]
local se1 = _se[satis_head]
	
* Hausman test for following regression
qui ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small
estimates store mod2b

/* E.16. Col.2. Initial coefficient: 16 instruments + controls */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 satis_dem ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef2 = _b[satis_head]
local se2 = _se[satis_head]

* Hausman test for following regression
qui ivreg2 satis_dem ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small 
estimates store mod3b

hausman mod3b mod1b
local temp_hausman = r(p)

/* E.16. Col.3. 16 instruments + additional endogenous variables */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 satis_dem ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod3
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
estadd scalar hausman = `temp_hausman'

local coef3 = _b[satis_head]
local se3 = _se[satis_head]

* Z-test 
local z_value = abs(`coef3'-`coef1')/sqrt(`se3'^2+`se1'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

* Hausman test for following regression
qui ivreg2 satis_dem ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small 
estimates store mod4b
hausman mod4b mod2b
local temp_hausman = r(p)
 
/* E.16. Col.4. 16 instruments + additional endogenous variables + controls */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 satis_dem ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod4
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean	
estadd scalar hausman = `temp_hausman'
local coef4 = _b[satis_head]
local se4 = _se[satis_head]

* Z-test 
local z_value = abs(`coef4'-`coef2')/sqrt(`se4'^2+`se2'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

local labgen: variable label satis_dem 

esttab mod1 mod2 mod3 mod4 using "3_output/2_OA/Tables/TableE16.tex", depvar keep(satis_head serious_h_csqc serious_e_csqc ) ///
	order(satis_head serious_h_csqc serious_e_csqc ) label replace ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat hausman wald, layout(@ @ @ @ @ @ @ @) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "Cragg-Donald statistic" "Hausman test p-value" "Z-test p-value")) ///
	collabels(none) mlabels(none) ///
	mgroups("`labgen'" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
	
	
**# Table E.17: Impact on support for democracy, additional regressors - 2SLS.
* Hausman test for following regression
qui ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small
estimates store mod1b

eststo clear

/* E.17. Col.1. Initial coefficient: 16 instruments */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod1
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef1 = _b[satis_head]
local se1 = _se[satis_head]
	
* Hausman test for following regression
qui ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small
estimates store mod2b

/* E.17. Col.2. Initial coefficient: 16 instruments + controls */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 democ ///
	(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef2 = _b[satis_head]
local se2 = _se[satis_head]

* Hausman test for following regression
qui ivreg2 democ ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small 
estimates store mod3b

hausman mod3b mod1b
local temp_hausman = r(p)

/* E.17. Col.3. 16 instruments + additional endogenous variables */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 democ ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod3
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
estadd scalar hausman = `temp_hausman'

local coef3 = _b[satis_head]
local se3 = _se[satis_head]

* Z-test 
local z_value = abs(`coef3'-`coef1')/sqrt(`se3'^2+`se1'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

* Hausman test for following regression
qui ivreg2 democ ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small 
estimates store mod4b
hausman mod4b mod2b
local temp_hausman = r(p)
 
/* E.17. Col.4. 16 instruments + additional endogenous variables + controls */
* to get the Cragg-Donald statistic: 
eststo: ivreg2 democ ///
	(satis_head serious_h_csqc serious_e_csqc = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod4
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean	
estadd scalar hausman = `temp_hausman'
local coef4 = _b[satis_head]
local se4 = _se[satis_head]

* Z-test 
local z_value = abs(`coef4'-`coef2')/sqrt(`se4'^2+`se2'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

local labgen: variable label democ 

esttab mod1 mod2 mod3 mod4 using "3_output/2_OA/Tables/TableE17.tex", depvar keep(satis_head serious_h_csqc serious_e_csqc ) ///
	order(satis_head serious_h_csqc serious_e_csqc ) label replace ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat hausman wald, layout(@ @ @ @ @ @ @ @) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "Cragg-Donald statistic" "Hausman test p-value" "Z-test p-value")) ///
	collabels(none) mlabels(none) ///
	mgroups("`labgen'" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))



/* *************************************************************************** */
/* E.7. Robusness to controlling for satisfaction for the regional government */
/* *************************************************************************** */

**** question not asked in countries where the survey was administered by CSA, we have to drop Australia and the US.
preserve
keep if country_str!= "Australia" & country_str!= "US"

**# Table E.18: Impact of the health and economic consequences of the crisis on satisfaction with the regional government.
eststo clear
eststo: reg satis_reg bad_health_situation bad_econ_situation , robust
get_mean
eststo: reg satis_reg bad_health_situation bad_econ_situation $controls $mv_controls i.country, robust
estadd local Controls "X", replace
estadd local Country_FE "X", replace
get_mean
esttab using "3_output/2_OA/Tables/TableE18.tex", r2 dep nocons ///
	keep(_cons bad_health_situation bad_econ_situation ) ///
	order(_cons bad_health_situation bad_econ_situation ) ///
	label replace 	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls Country_FE N r2 av, fmt(%15.0fc %15.0fc %15.0fc %6.3f %6.3f ) layout(@ @ @ @ @) ///
	labels("Individual controls" "Country FE" Observations R2 "Outcome mean")) ///
	collabels(none) mlabels(none) ///
	mgroups("Satisfaction with the regional government" , pattern(1 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) 

	
**# Table E.19: Impact of satisfaction with the regional government on satisfaction with democracy.
eststo clear
/* E.19. Col 1. Initial coefficient: satis_head only */
* Hausman test for following regression
qui ivreg2 satis_dem ///
(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small
estimates store mod1b

eststo: ivreg2 satis_dem ///
(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod1
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef1 = _b[satis_head]
local se1 = _se[satis_head]

/* E.19. Col 2. Initial coefficient: satis_head only + controls */
* Hausman test for following regression
qui ivreg2 satis_dem ///
(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small							
estimates store mod2b

eststo: ivreg2 satis_dem ///
(satis_head = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
local coef2 = _b[satis_head]
local se2 = _se[satis_head]

/* E.19. Col 3. satis_reg only */
eststo: ivreg2 satis_dem ///
(satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust

estimates store mod1r
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean

/* E.19. Col 4. satis_reg only + controls*/
eststo: ivreg2 satis_dem ///
(satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust

estimates store mod2r
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean

/* E.19. Col 5. satis_head + satis_reg */
* Hausman test for following regression
qui ivreg2 satis_dem ///
(satis_head satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small 
estimates store mod3b
hausman mod3b mod1b
local temp_hausman = r(p)

eststo: ivreg2 satis_dem ///
(satis_head satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3), small robust
 
estimates store mod3
estadd scalar fstat = e(widstat)
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean
estadd scalar hausman = `temp_hausman'
local coef3 = _b[satis_head]
local se3 = _se[satis_head]

* Z-test 
local z_value = abs(`coef3'-`coef1')/sqrt(`se3'^2+`se1'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2

/* E.19. Col 6. satis_head + satis_reg + controls*/
* Hausman test for following regression
qui ivreg2 satis_dem ///
(satis_head satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small 
estimates store mod4b
hausman mod4b mod2b
local temp_hausman = r(p)

* to get the Cragg-Donald statistic: 
eststo: ivreg2 satis_dem ///
(satis_head satis_reg = TH1_TE1 TH1_TE2 TH1_TE3 TH1_TE4 TH2_TE1 TH2_TE2 TH2_TE3 TH2_TE4 TH3_TE1 TH3_TE2 TH3_TE3 TH3_TE4 TH4_TE1 TH4_TE2 TH4_TE3) $controls $mv_controls i.country, small robust 

estimates store mod4
estadd scalar fstat = e(widstat)
estadd local CFE "X", replace
estadd local Controls "X", replace
estadd local IV "16 IVs"
estadd local nothing nothing2 = " "
get_mean

estadd scalar hausman = `temp_hausman'
local coef4 = _b[satis_head]
local se4 = _se[satis_head]

* Z-test 
local z_value = abs(`coef4'-`coef2')/sqrt(`se4'^2+`se2'^2)
di (1-normal(`z_value'))*2
estadd scalar wald = (1-normal(`z_value'))*2


local labgen: variable label satis_dem 

esttab mod1 mod2 mod1r mod2r mod3 mod4 using "3_output/2_OA/Tables/TableE19.tex", depvar keep(satis_head satis_reg ) ///
	order(satis_head satis_reg serious_h_csqc serious_e_csqc ) label replace ///
	cells(b(star fmt(%15.3fc)) se(par fmt(%15.3fc))) interaction(" $\times$ ") ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	stats(Controls CFE N av IV fstat hausman wald, layout(@ @ @ @ @ @ @ @) fmt(%15s %15s %15.0fc %9.3f %9.3f %9.3f %9.3f %9.3f %9.3f) ///
	labels("Individual controls" "Country FE" Observations "Outcome mean" "Instruments" "Cragg-Donald statistic" "Hausman test p-value" "Z-test p-value")) ///
	collabels(none) mlabels(none) ///
	mgroups("`labgen'" , pattern(1 0 0 0) ///
	prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

restore	
